<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BMI</title>
</head>
<body>
<input type="text" id="h"/>m
<input type="text" id="w"/>kg
<input type="button" id="btn1" value="计算BMI">
<script>
document.getElementById("btn1").onclick = function () {
var height = document.getElementById("h").value;
var weight = document.getElementById("w").value;
var bmi = weight / (height * height);
alert(bmi);
    }
</script>
</body>
</html>